************** 	REPLICATION FILES FOR FENZL, MICHELE. "A SHADOW ON DEMOCRACY?"
**************  THE SHADOW ECONOMY AND GOVERNMENT RESPONSIVENESS. EUROPEAN JOURNAL
**************  OF POLITICAL RESEARCH. -> Analyses in the Appendix

**************  Contact info of author: michele.fenzl@maastrichtuniversity.nl

**************  The analyses were originally produced using Stata 14. 
**************  To reproduce Figure 1 you need to install the package grinter:
**************  To do so use the command findit grinter 
**************  Then, select grinter from https://myweb.uiowa.edu/fboehmke/stata (V1.08)

use "FenzlM_Democracy_in_shadow_EJPR.dta", clear

/// Figure A1
graph box totgen if sample_main == 1, horizontal over(cname) scheme(s2mono) graphr(c(white))	

/// Appendix B (Table A3)
xtreg wdi_taxrev l.(shec_se real openc) if sample_ == 1, fe cluster(cname)

/// Appendix C (Table A4)
xtpcse d.totgen d.(wdi_taxrev real unemp elderly vi_udr) if sample_ == 1

/// Appendix D (Table A5)
xtpcse d.corpo d.shec_se i.cc if sample_main == 1
xtpcse d.corpo D.(shec_se real unemp elderly vi_udr) i.cc if sample_main == 1 

xtpcse d.ictd_taxgs d.shec_se i.cc if sample_main == 1
xtpcse d.ictd_taxgs D.(shec_se real unemp elderly vi_udr) i.cc if sample_main == 1 

xtpcse d.ictd_taxinc d.shec_se i.cc if sample_main == 1
xtpcse d.ictd_taxinc D.(shec_se real unemp elderly vi_udr) i.cc if sample_main == 1 

xtpcse d.ictd_taxindirect d.shec_se i.cc if sample_main == 1
xtpcse d.ictd_taxindirect D.(shec_se real unemp elderly vi_udr) i.cc if sample_main == 1 

xtpcse d.ictd_taxprop d.shec_se i.cc if sample_main == 1
xtpcse d.ictd_taxprop D.(shec_se real unemp elderly vi_udr) i.cc if sample_main == 1 

/// Appendix E (Table A6)
xtpcse d.totgen l.totgen d.shec_se l.shec_se if sample_main == 1
xtpcse d.corpo l.corpo d.shec_se l.shec_se if sample_main == 1

/// Appendix F (Table A7)
xtpcse totgen l.shec_se l.real l.wdi_trade l.empra l.ictd_taxind if sample_main == 1
xtpcse corpo l.shec_se l.real l.wdi_trade l.empra l.ictd_taxind if sample_main == 1

/// Appendix G (Table A8)
xtpcse d.corpo l.corpo d.cmedianaug l.cmedianaug if sample_main == 1
xtpcse d.corpo l.corpo d.cmedianaug l.cmedianaug i.cc if sample_main == 1
xtpcse d.totgen l.totgen d.cmedianaug l.cmedianaug if sample_main == 1
xtpcse d.totgen l.totgen d.cmedianaug l.cmedianaug i.cc if sample_main == 1

/// Appendix I (Table A10 & Table A11)
gen dtotgen = d.totgen
gen ltotgen = l.totgen
gen dcmedianaug = d.cmedianaug
gen lcmedianaug = l.cmedianaug
gen dshec_se = d.shec_se
gen lshec_se = l.shec_se
gen Dint_cmedianaugXshec_se = d.cmedianaug * d.shec_se
gen Lint_cmedianaugXshec_se = l.cmedianaug * l.shec_se
gen dreal = d.real
gen lreal = l.real
gen dvdem_corr = d.vdem_corr
gen lvdem_corr = l.vdem_corr
gen dopenc = d.openc
gen lopenc = l.openc
gen dunemp = d.unemp
gen lunemp = l.unemp
gen dwdi_trade = d.wdi_trade
gen lwdi_trade = l.wdi_trade
gen dempra = d.empra
gen lempra = l.empra
gen dictd_taxind = d.ictd_taxind
gen lictd_taxind = l.ictd_taxind
xtpcse dtotgen ltotgen dshec_se dcmedianaug Dint_cmedianaugXshec_se lcmedianaug lshec_se Lint_cmedianaugXshec_se dreal lreal dvdem_corr lvdem_corr dwdi_trade lwdi_trade dempra lempra dictd_taxind lictd_taxind i.fed i.prop i.cc if sample_main == 1

xtpcse d.totgen l.totgen d.cmedianaug l.cmedianaug d.shec_se l.shec_se c.d.cmedianaug##c.d.shec_se c.l.cmedianaug##c.l.shec_se d.real l.real d.vdem_corr l.vdem_corr d.wdi_trade l.wdi_trade d.empratio l.empratio d.ictd_taxind l.ictd_taxind d.sstran l.sstran d.inflation l.inflation d.debt l.debt i.cc if sample_main == 1

/// Appendix J (Figure A2)

set more off
xtpcse dtotgen ltotgen dshec_se dcmedianaug Dint_cmedianaugXshec_se lcmedianaug lshec_se Lint_cmedianaugXshec_se dreal lreal dvdem_corr lvdem_corr dwdi_trade lwdi_trade dempra lempra dictd_taxind lictd_taxind i.cc if sample_main == 1
	grinter dcmedianaug, int(Dint_cmedianaugXshec_se) const(dshec_se) yline(0, lpattern(-...-) lc(gs7)) kdensity kdop(lc(gs13) lpattern(shortdash)) ciop(recast(rarea, fc(gs14))) nonote scheme(s2mono) title(ECM: Short-term) graphr(c(white)) saving(g2a.gph, replace)
	grinter lcmedianaug, int(Lint_cmedianaugXshec_se) const(lshec_se) yline(0, lpattern(-...-) lc(gs7)) kdensity kdop(lc(gs13) lpattern(shortdash)) ciop(recast(rarea, fc(gs14))) nonote scheme(s2mono) title(ECM: Long-term) graphr(c(white)) saving(g3a.gph, replace)
	graph combine g3a.gph g2a.gph, holes(2) graphr(c(white))

/// Appendix K (Table A12)
gen mv_abs = abs(d.cmedianaug)
xtile mv_abs_med = mv_abs, nq(2)

set more off
xtpcse dtotgen ltotgen dcmedianaug lcmedianaug dshec_se lshec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se dreal lreal dvdem_corr lvdem_corr dwdi_trade lwdi_trade dempra lempra dictd_taxind lictd_taxind i.cc if sample_main == 1 & mv_abs_med == 2, pair
	
/// Appendix L (Table A13)

reg totgen year if cc == 1
predict res_1, res
reg totgen year if cc == 2
predict res_2, res
reg totgen year if cc == 5
predict res_5, res
reg totgen year if cc == 7
predict res_7, res
reg totgen year if cc == 8
predict res_8, res
reg totgen year if cc == 9
predict res_9, res
reg totgen year if cc == 10
predict res_10, res
reg totgen year if cc == 12
predict res_12, res
reg totgen year if cc == 13
predict res_13, res
reg totgen year if cc == 16
predict res_16, res
reg totgen year if cc == 18
predict res_18, res
reg totgen year if cc == 22
predict res_22, res
reg totgen year if cc == 23
predict res_23, res
reg totgen year if cc == 24
predict res_24, res
reg totgen year if cc == 25
predict res_25, res
 
replace res_1 = . if cc != 1
replace res_2 = . if cc != 2
replace res_5 = . if cc != 5
replace res_7 = . if cc != 7
replace res_8 = . if cc != 8
replace res_9 = . if cc != 9
replace res_10 = . if cc != 10
replace res_12 = . if cc != 12
replace res_13 = . if cc != 13
replace res_16 = . if cc != 16
replace res_18 = . if cc != 18
replace res_22 = . if cc != 22
replace res_23 = . if cc != 23
replace res_24 = . if cc != 24
replace res_25 = . if cc != 25
 
gen res_detrend = res_1
replace res_detrend = res_2 if res_2 != .
replace res_detrend = res_5 if res_5 != .
replace res_detrend = res_7 if res_7 != .
replace res_detrend = res_8 if res_8 != .
replace res_detrend = res_9 if res_9 != .
replace res_detrend = res_10 if res_10 != .
replace res_detrend = res_12 if res_12 != .
replace res_detrend = res_13 if res_13 != .
replace res_detrend = res_16 if res_16 != .
replace res_detrend = res_18 if res_18 != .
replace res_detrend = res_22 if res_22 != .
replace res_detrend = res_23 if res_23 != .
replace res_detrend = res_24 if res_24 != .
replace res_detrend = res_25 if res_25 != .

rename res_detrend totgen_detrended
label var totgen_detrended "Welfare generosity (de-trended)"

xtunitroot ips totgen_detrended if sample_main == 1
/// p-value 0.0617
xtunitroot ips totgen_detrended if sample_main == 1 & cname != "Germany"
/// p-value 0.0281

xtpcse d.totgen_detrended l.totgen_detrended d.cmedianaug l.cmedianaug d.shec_se l.shec_se i.cc if sample_main == 1
xtpcse d.totgen_detrended l.totgen_detrended d.cmedianaug l.cmedianaug d.shec_se l.shec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se i.cc if sample_main == 1
xtpcse d.totgen_detrended l.totgen_detrended d.cmedianaug l.cmedianaug d.shec_se l.shec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se d.real l.real d.vdem_corr l.vdem_corr d.wdi_trade l.wdi_trade d.empratio l.empratio d.ictd_taxind l.ictd_taxind i.cc if sample_main == 1

/// Appendix M (Table A14)
set more off
gen govtrile_rs2 = ( govt_rile - -50 ) / ( 50- -50 ) * 10

xtpcse dtotgen ltotgen d.govtrile_rs2 l.govtrile_rs2 dshec_se lshec_se i.cc if sample_main == 1
xtpcse dtotgen ltotgen c.d.govtrile_rs2##c.d.shec_se c.l.govtrile_rs2##c.l.shec_se i.cc if sample_main == 1
xtpcse dtotgen ltotgen c.d.govtrile_rs2##c.d.shec_se c.l.govtrile_rs2##c.l.shec_se d.real l.real d.vdem_corr l.vdem_corr d.wdi_trade l.wdi_trade d.empra l.empra d.ictd_taxind l.ictd_taxind d.cmedianaug l.cmedianaug i.cc if sample_main == 1

/// Appendix N (Table A15)
xtpcse d.govt_rile l.govt_rile dcmedianaug lcmedianaug dshec_se lshec_se if sample_main == 1
xtpcse d.govt_rile l.govt_rile dcmedianaug lcmedianaug dshec_se lshec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se if sample_main == 1
xtpcse d.govt_rile l.govt_rile dcmedianaug lcmedianaug dshec_se lshec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se d.real l.real d.vdem_corr l.vdem_corr d.wdi_trade l.wdi_trade d.empra l.empra d.ictd_taxind l.ictd_taxind if sample_main == 1
xtpcse d.govt_rile l.govt_rile dcmedianaug lcmedianaug dshec_se lshec_se Dint_cmedianaugXshec_se Lint_cmedianaugXshec_se d.real l.real d.vdem_corr l.vdem_corr d.wdi_trade l.wdi_trade d.empra l.empra d.ictd_taxind l.ictd_taxind i.cc if sample_main == 1

/// Appendix O (Table A16)

xtpcse d.totgen l.totgen (c.d.cmedianaug##c.d.shec_se) l.(c.cmedianaug##c.shec_se) i.cc if sample_main == 1 
xtpcse d.totgen l2.totgen l.(c.d.cmedianaug##c.d.shec_se) l2.(c.cmedianaug##c.shec_se) i.cc if sample_main == 1 

/// Appendix H (Table A9)
use "ESS1-9e01_1-2.dta", clear
keep if cntry == "AT" | cntry == "BE" | cntry == "FI" | cntry == "FR" | cntry == "DE" | cntry == "IE" | cntry == "IT" | cntry == "NL" | cntry == "PT" | cntry == "ES" | cntry == "GB" | cntry == "CH" | cntry == "DK" | cntry == "GR"
label var gincdif "Opposing redistribution"
reg lrscale gincdif i.essround, cluster(cntry)

use "ESS8e02_2.dta", clear
keep if cntry == "AT" | cntry == "BE" | cntry == "FI" | cntry == "FR" | cntry == "DE" | cntry == "IE" | cntry == "IT" | cntry == "NL" | cntry == "PT" | cntry == "ES" | cntry == "GB" | cntry == "CH"
label var lrscale "Rightward self-positioning"
label var gincdif "Opposing redistribution"
label var gvrfgap "Opposing refugees"
label var inctxff "Opposing taxing fossil fuels"
label var hmsacld "Opposing adoption to same-sex couples"
reg lrscale gincdif gvrfgap inctxff hmsacld , cluster(cntry)
